import '../../../../common/window_pop/public_btn_tem.dart';

class AudioRecordConfigData {
  String? title;
  EditArea? editArea;
  PlayArea? playArea;

  AudioRecordConfigData({this.title, this.editArea, this.playArea});

  AudioRecordConfigData.fromJson(Map<String, dynamic> json) {
    if (json["title"] is String) {
      title = json["title"];
    }
    if (json["editArea"] is Map) {
      editArea = json["editArea"] == null ? null : EditArea.fromJson(json["editArea"]);
    }
    if (json["playArea"] is Map) {
      playArea = json["playArea"] == null ? null : PlayArea.fromJson(json["playArea"]);
    }
  }

  static List<AudioRecordConfigData> fromList(List<Map<String, dynamic>> list) {
    return list.map(AudioRecordConfigData.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["title"] = title;
    if (editArea != null) {
      json["editArea"] = editArea?.toJson();
    }
    if (playArea != null) {
      json["playArea"] = playArea?.toJson();
    }
    return json;
  }
}

class PlayArea {
  int? view;
  Tips? tips;
  Voice? voice;
  List<PublicBtnItem>? btns;

  PlayArea({this.view, this.tips, this.voice, this.btns});

  PlayArea.fromJson(Map<String, dynamic> json) {
    if (json["view"] is num) {
      view = (json["view"] as num).toInt();
    }
    if (json["tips"] is Map) {
      tips = json["tips"] == null ? null : Tips.fromJson(json["tips"]);
    }
    if (json["voice"] is Map) {
      voice = json["voice"] == null ? null : Voice.fromJson(json["voice"]);
    }
    if (json["btns"] is List) {
      btns = json["btns"] == null ? null : (json["btns"] as List).map((e) => PublicBtnItem.fromJson(e)).toList();
    }
  }

  static List<PlayArea> fromList(List<Map<String, dynamic>> list) {
    return list.map(PlayArea.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["view"] = view;
    if (tips != null) {
      json["tips"] = tips?.toJson();
    }
    if (voice != null) {
      json["voice"] = voice?.toJson();
    }
    if (btns != null) {
      json["btns"] = btns?.map((e) => e.toJson()).toList();
    }
    return json;
  }
}

class Voice {
  String? src;
  String? long;

  Voice({this.src, this.long});

  Voice.fromJson(Map<String, dynamic> json) {
    if (json["src"] is String) {
      src = json["src"];
    }
    if (json["long"] is String) {
      long = json["long"];
    }
  }

  static List<Voice> fromList(List<Map<String, dynamic>> list) {
    return list.map(Voice.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["src"] = src;
    json["long"] = long;
    return json;
  }
}

class Tips {
  String? text;
  String? desc;

  Tips({this.text, this.desc});

  Tips.fromJson(Map<String, dynamic> json) {
    if (json["text"] is String) {
      text = json["text"];
    }
    if (json["desc"] is String) {
      desc = json["desc"];
    }
  }

  static List<Tips> fromList(List<Map<String, dynamic>> list) {
    return list.map(Tips.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["text"] = text;
    json["desc"] = desc;
    return json;
  }
}

class EditArea {
  int? view;
  List<RecordKind>? recordKind;
  List<RecordAudioBtn>? btns;

  EditArea({this.view, this.recordKind, this.btns});

  RecordAudioBtn? get voiceRecord => btns!.where((e) => e.key == "voiceRecord").toList().first;

  EditArea.fromJson(Map<String, dynamic> json) {
    if (json["view"] is num) {
      view = (json["view"] as num).toInt();
    }
    if (json["recordKind"] is List) {
      recordKind =
          json["recordKind"] == null ? null : (json["recordKind"] as List).map((e) => RecordKind.fromJson(e)).toList();
    }
    if (json["btns"] is List) {
      btns = json["btns"] == null ? null : (json["btns"] as List).map((e) => RecordAudioBtn.fromJson(e)).toList();
    }
  }

  static List<EditArea> fromList(List<Map<String, dynamic>> list) {
    return list.map(EditArea.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["view"] = view;
    if (recordKind != null) {
      json["recordKind"] = recordKind?.map((e) => e.toJson()).toList();
    }
    if (btns != null) {
      json["btns"] = btns?.map((e) => e.toJson()).toList();
    }
    return json;
  }
}

class RecordAudioBtn {
  String? key;
  String? title;
  int? view;
  dynamic display;
  Click? click;

  RecordAudioBtn({this.key, this.title, this.view, this.display, this.click});

  RecordAudioBtn.fromJson(Map<String, dynamic> json) {
    if (json["key"] is String) {
      key = json["key"];
    }
    if (json["title"] is String) {
      title = json["title"];
    }
    if (json["view"] is num) {
      view = (json["view"] as num).toInt();
    }
    display = json["display"];
    if (json["click"] is Map) {
      click = json["click"] == null ? null : Click.fromJson(json["click"]);
    }
  }

  static List<RecordAudioBtn> fromList(List<Map<String, dynamic>> list) {
    return list.map(RecordAudioBtn.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["key"] = key;
    json["title"] = title;
    json["view"] = view;
    json["display"] = display;
    if (click != null) {
      json["click"] = click?.toJson();
    }
    return json;
  }
}

class Click {
  String? react;
  String? option;
  Params? params;

  Click({this.react, this.option, this.params});

  Click.fromJson(Map<String, dynamic> json) {
    if (json["react"] is String) {
      react = json["react"];
    }
    if (json["option"] is String) {
      option = json["option"];
    }
    if (json["params"] is Map) {
      params = json["params"] == null ? null : Params.fromJson(json["params"]);
    }
  }

  static List<Click> fromList(List<Map<String, dynamic>> list) {
    return list.map(Click.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["react"] = react;
    json["option"] = option;
    if (params != null) {
      json["params"] = params?.toJson();
    }
    return json;
  }
}

class Params {
  Value? value;

  Params({this.value});

  Params.fromJson(Map<String, dynamic> json) {
    if (json["value"] is Map) {
      value = json["value"] == null ? null : Value.fromJson(json["value"]);
    }
  }

  static List<Params> fromList(List<Map<String, dynamic>> list) {
    return list.map(Params.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    if (value != null) {
      json["value"] = value?.toJson();
    }
    return json;
  }
}

class Value {
  String? minlong;
  String? maxlong;

  Value({this.minlong, this.maxlong});

  Value.fromJson(Map<String, dynamic> json) {
    if (json["minlong"] is String) {
      minlong = json["minlong"];
    }
    if (json["maxlong"] is String) {
      maxlong = json["maxlong"];
    }
  }

  static List<Value> fromList(List<Map<String, dynamic>> list) {
    return list.map(Value.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["minlong"] = minlong;
    json["maxlong"] = maxlong;
    return json;
  }
}

class RecordKind {
  String? key;
  String? btn;
  String? title;
  TextItem? text;

  RecordKind({this.key, this.btn, this.title, this.text});

  RecordKind.fromJson(Map<String, dynamic> json) {
    if (json["key"] is String) {
      key = json["key"];
    }
    if (json["btn"] is String) {
      btn = json["btn"];
    }
    if (json["title"] is String) {
      title = json["title"];
    }
    if (json["text"] is Map) {
      text = json["text"] == null ? null : TextItem.fromJson(json["text"]);
    }
  }

  static List<RecordKind> fromList(List<Map<String, dynamic>> list) {
    return list.map(RecordKind.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["key"] = key;
    json["btn"] = btn;
    json["title"] = title;
    if (text != null) {
      json["text"] = text?.toJson();
    }
    return json;
  }
}

class TextItem {
  int? id;
  String? txt;

  TextItem({this.id, this.txt});

  TextItem.fromJson(Map<String, dynamic> json) {
    if (json["id"] is num) {
      id = (json["id"] as num).toInt();
    }
    if (json["txt"] is String) {
      txt = json["txt"];
    }
  }

  static List<TextItem> fromList(List<Map<String, dynamic>> list) {
    return list.map(TextItem.fromJson).toList();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json["id"] = id;
    json["txt"] = txt;
    return json;
  }
}
